<!DOCTYPE html>
<html lang="en">
  <head>
    <?php echo Yaf_View_Simple::render('header.phtml'); ?>
    <script type="text/javascript">
     var app = {
         article_rows : <?php echo $count; ?>
     }
    </script>
    
  </head>
  <body>
    <?php echo Yaf_View_Simple::render('nav.phtml'); ?>
    <div class="slide-wrap">
      <div class="slide" >
        <div id="carousel-generic" class="carousel slide" data-ride="carousel">
          <ol class="carousel-indicators">
            <?php $len = count($slide); for($i=0; $i<$len; $i++){ ?>
            <li data-target="#carousel-generic" data-slide-to="<?php echo $i; ?>" class=""></li>
            <?php } ?>
          </ol>
          <div class="carousel-inner" role="listbox">
            <?php foreach($slide as $key=>$s){ ?>
            <?php if($key == 0){ ?>
            <div class="item active">
              <?php }else{ ?>
              <div class="item">
                <?php } ?>                
                <img src="<?php echo $s['picture']; ?>" data-holder-rendered="true" width="100%">
              </div>
              <?php } ?>
            </div>
          </div>
          <a class="left carousel-control" href="#carousel-generic" role="button" data-slide="prev">
            <span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
            <span class="sr-only">Previous</span>
          </a>
          <a class="right carousel-control" href="#carousel-generic" role="button" data-slide="next">
            <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
            <span class="sr-only">Next</span>
          </a>
        </div>
      </div>
    </div> <!--     ./ container -->
    <div class="container margin-top-30" >
      <div class="row">
        <?php foreach($cat as $value) { ?>
        
        <div class="col-lg-12">
          <div class="page-header clearfix" >
            <a href="<?php echo $value['link']; ?>"><?php echo $value['name']; ?></a>
          </div>
        </div>
        <div class="list-category" >
          <?php if(isset($value['_'])){ foreach($value['_'] as $v){ ?>
          <div class="col-lg-3" style="margin-bottom:15px">
            <img src="<?php echo $v['image']; ?>" class=""/>
            <div style="padding:10px 15px;background:#eeeeee"><a href="<?php echo $v['link']; ?>"><?php echo $v['name']; ?></a></div>
          </div>
          
          <?php }} ?>
        </div>
        <?php } ?>
        <div class="col-lg-9">
          <div class="page-header" >
            <h3>Last Articles</h3>
          </div>
          <div class="content" id="content">
            <?php foreach($art as $value) { ?>
            <div class="index-article-list">
              <h3><a href="/index/article/post?id=<?php echo $value['id']; ?>"><?php echo $value['title']; ?></a></h3>
              <div class="info" >
                <span><i class="glyphicon glyphicon-user" ></i><?php echo $value['author']; ?></span>
                <span><i class="glyphicon glyphicon-time" ></i><?php echo $value['create_time']; ?></span>
              </div>
            </div>
            <?php } ?>
          </div>
          <div class="pagination" id ="pagination">
            <ul>
            </ul>
          </div>
        </div>
          <div class="col-lg-3" >
            <div class="page-header" >
              <h3>INFO:</h3>
            </div>
            <div class="adress" >
              <h3>xxxxxx</h3>
            </div>
          </div>
        </div>
        <div class="col-lg-12" >
          <div class="row" >
          <div class="form-search bg-info" style="padding:30px">
            <form class="form" action="/index/article/search" >
              <div class="input-group">
                <input type="search" name="keyword" class="form-control" placeholder="title/tag" required>
                <span class="input-group-btn">
                  <button class="btn btn-default" type="submit">Search</button>
                </span>
              </div><!-- /input-group -->
            </form>
          </div>
          </div>
        </div>
      </div>
    </div>
    </div>
    <footer class="footer">
      <?php echo Yaf_View_Simple::render('footer.phtml'); ?>
    </footer>
    <script src="/asset/index/js/ajaxpage.js" type="text/javascript"></script>
    <script type="text/javascript">
     ;(function(){
         var bind = function(){
             var pagination = $("#pagination");
             var _a = pagination.find("li a");
             _a.on('click',function(){
                 var page = $(this).text();
                 page = parseInt(page);
                 if(page == 1){
                     page = 0;
                 }else{
                     page = (page-1)*10;
                 }
                 $.ajax({
                     type:"post",
                     url :"/index/index/page",
                     data:{page : page},
                     success:function(e){
                         $("#content").html(e)
                     },
                     dataType: 'text',
                 });            
             })

         }
         bind();
         
     }())
    </script>
  </body>
</html>

